﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PropertyChangedEventHandler
{
    public delegate void DateChangedHandler(object sender, DateChangedEventArgs e);
    public partial class Form1 : Form, IDateChanged
    {
        private CustomizedObject myObject;
        public Form1()
        {
            InitializeComponent();

            // 初始化CustomizedObject对象

            myObject = new CustomizedObject { Date = DateTime.Now };
            // 绑定对象的属性到label1

            label1.DataBindings.Add("Text", myObject, "Date");
        }

        public event DateChangedHandler DateChanged;

        private void button1_Click(object sender, EventArgs e)
        { // 点击按钮改变对象的属性值

            myObject.Date = myObject.Date.AddDays(1);

        }
    }
}
